package cn.edu.wfit.modules.infomanagement.controller;

import java.util.List;

import cn.edu.wfit.common.core.utils.poi.ExcelUtil;
import cn.edu.wfit.common.core.web.controller.BaseController;
import cn.edu.wfit.common.core.web.domain.AjaxResult;
import cn.edu.wfit.common.core.web.page.TableDataInfo;
import cn.edu.wfit.common.log.annotation.Log;
import cn.edu.wfit.common.log.enums.BusinessType;
import jakarta.servlet.http.HttpServletResponse;
import cn.edu.wfit.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.edu.wfit.modules.infomanagement.domain.TBus;
import cn.edu.wfit.modules.infomanagement.service.ITBusService;


/**
 * 存储班车基础配置Controller
 * 
 * @author zhanghao
 * @date 2025-11-07
 */
@RestController
@RequestMapping("/bus")
public class TBusController extends BaseController
{
    @Autowired
    private ITBusService tBusService;

    /**
     * 查询存储班车基础配置列表
     */
    @RequiresPermissions("system:bus:list")
    @GetMapping("/list")
    public TableDataInfo list(TBus tBus)
    {
        startPage();
        List<TBus> list = tBusService.selectTBusList(tBus);
        return getDataTable(list);
    }

    /**
     * 导出存储班车基础配置列表
     */
    @RequiresPermissions("system:bus:export")
    @Log(title = "存储班车基础配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TBus tBus)
    {
        List<TBus> list = tBusService.selectTBusList(tBus);
        ExcelUtil<TBus> util = new ExcelUtil<TBus>(TBus.class);
        util.exportExcel(response, list, "存储班车基础配置数据");
    }

    /**
     * 获取存储班车基础配置详细信息
     */
    @RequiresPermissions("system:bus:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tBusService.selectTBusById(id));
    }

    /**
     * 新增存储班车基础配置
     */
    @RequiresPermissions("system:bus:add")
    @Log(title = "存储班车基础配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TBus tBus)
    {
        return toAjax(tBusService.insertTBus(tBus));
    }

    /**
     * 修改存储班车基础配置
     */
    @RequiresPermissions("system:bus:edit")
    @Log(title = "存储班车基础配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TBus tBus)
    {
        return toAjax(tBusService.updateTBus(tBus));
    }

    /**
     * 删除存储班车基础配置
     */
    @RequiresPermissions("system:bus:remove")
    @Log(title = "存储班车基础配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tBusService.deleteTBusByIds(ids));
    }
}
